import Vue from 'vue'
import VueRouter, { RouteConfig } from 'vue-router'
import Home from '../views/Home.vue' // pc端
import mobile from '../views/mobile/moveweb.vue'

Vue.use(VueRouter)

const routes: Array<RouteConfig> = [
  {
    // pc端
    path: '/',
    name: 'Home',
    component: Home,
  },
  {
    // 手机端
    path: '/m',
    name: 'Moveweb',
    component: mobile,
  },
  {
    // PC端404
    path: '/404',
    name: 'Page404',
    component: () => import('@/views/404.vue'),
  },
  {
    // pc端投放页
    path: '/putin',
    name: 'Putin',
    component: () => import('@/views/putin.vue'),
  },
  {
    // 手机端404
    path: '/move404',
    name: 'Move404',
    component: () => import('@/views/mobile/move404.vue'),
  },
  {
    // 手机端引导页
    path: '/guide',
    name: 'Guide',
    component: () => import('@/views/mobile/guide.vue'),
  },
  {
    // 重定向手机端
    path: '/home',
    name: 'Moveweb',
    component: mobile,
  },
  {
    // 手机端下载页
    path: '/download',
    name: 'Download',
    component: () => import('../views/mobile/download.vue'),
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue'),
  },
  { path: '*', redirect: '/404' },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
// 判断是手机还是pc-- //判断是否为移动端的设备，是移动端的话  跳转  mobile 页面
// if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
//   routes.splice(0, 1)
//   router.push({ name: 'Moveweb' })
// } else {
//   routes.splice(1, 1)
//   router.push({ name: 'Home' })
// }
export default router
